<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('approval_records', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('company_id')->default(0)->index();
            $table->unsignedBigInteger('approval_id')->default(0)->index();
            $table->unsignedBigInteger('node_id')->default(0)->index();
            $table->unsignedBigInteger('role_id')->default(0)->index();
            $table->unsignedBigInteger('admin_id')->default(0)->index();
            $table->string('result')->default('afoot')->comment('审批状态：afoot-审批中 approved-已通过 rejected-已驳回 transfer-转审');
            $table->string('comment')->nullable()->comment('审批意见');
            $table->unsignedBigInteger('trans_to')->default(0)->comment('转审给用户ID');
            $table->unsignedBigInteger('level')->default(0)->comment('到哪一级');
            $table->timestamp('processed_at')->comment('处理时间');
            $table->string('files')->nullable()->comment('附件');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('approval_records');
    }
};
